﻿var Aaw = 0;
function Alf() {
	return (self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight);
}
function Aml() {
	return (document.documentElement.offsetWidth || document.body.offsetWidth);
}
/***********对话框移动效果***************/
var isworking=0;//1拖动状态
var topmore=0;//top Number
var leftmore=0;//top Number
//mouse down or up
function mouseDownOrUp(index){
 if(index==1)//mouse down
 {
 isworking=1;
 
 
   //原始坐标
  var divy=parseInt($("tipIFrame").style.top.substring(0,$("tipIFrame").style.top.indexOf("px")));
  var divx=parseInt($("tipIFrame").style.left.substring(0,$("tipIFrame").style.left.indexOf("px")));

  //鼠标坐标
  var eventy=parseInt(event.y);
  var eventx=parseInt(event.x);
  
  //坐标差
  topmore=(eventy-divy);
  leftmore=(eventx-divx);
 }else//mouse up
 {
  isworking=0;
 }
} 

//drag
function dialogmove(event){
 if(isworking==1)
 {
  //鼠标坐标
  var eventy=parseInt(event.y);
  var eventx=parseInt(event.x);

  //坐标差
  eventx=eventx-leftmore;
  eventy=eventy-topmore;

  $("tipIFrame").style.top=eventy+"px";
  $("tipIFrame").style.left=eventx+"px";
 }
}

///////////////////////////////////////
function MyAlert(msg, tit, okCallbak, isConfirm, def, cancelCallbak) {
	setHideEleByTagName("select","none");
	var br = document.createElement("DIV");
	br.id = "dvMyAlert";
	document.body.appendChild(br);
	tit = tit || "系统提示";
	var u = "";
	u += "<div class=\"main1\" id=\"tipIFrame\" style=\"width:300px;position:absolute;z-index:999\" id=\"sysMsgWin\">";
u += "<div class=\"title\" style=\"width:303px\"><div class=\"title_l\"></div><div class=\"title_m\">";
//	u += "<div class=\"title\" style='width:303px;cursor: move;'><div class=\"title_l\"></div><div class=\"title_m\" onmousedown='mouseDownOrUp(1);' onmouseup='mouseDownOrUp(2);' onmousemove='dialogmove(event);' onselectstart='return false;' >";
	u += tit + "</div><div id=\"btnSysInfoClose\" title=\"关闭\" class=\"title_c\"></div></div>";
	u += "<div class=\"content_no\"><table bgcolor=\"ffffff\" width=\"100%\" border=\"0\"><tr><td height=\"80\" width=\"50\" valign=\"middle\">";
	u += "<div class=\"img_info\" style=\"width:50px;height:50px\"></div></td><td style=\"word-break:break-all;\">";
	u += msg + "</td></tr><tr><td colspan=\"2\" align=\"center\">";
	u += "<input type=\"button\" value=\" 确 定 \" class=\"button2\" id=\"btnSysMsgOk\" />";
	if(isConfirm){
		u += "&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"button\" value=\" 取 消 \" class=\"button2\" id=\"btnSysMsgNo\" />";
	}
		u += "</td></tr></table></div></div>";
	var Aok = "100%";
	var Anc = "100%";
	if (document.body.scrollHeight > Alf()) {
		Anc = document.body.scrollHeight;
	}
	var Abc = "";
	Abc = "-moz-opacity:0.07;";
	Abc += "filter:alpha(opacity=7);";
	u += "<div style=\"position:absolute;z-index:998;top:0;left:0;width:" + Aok + ";height:" + Anc + ";" + Abc + "background-color:#000000\"></div>";
	br.innerHTML = u;
	var ag = br.firstChild;
	var h = ag.offsetHeight;
	var w = ag.offsetWidth;
	var scrollTop = document.body.scrollTop;
	var x = (Aml() - w) / 2;
	var y = (Alf() - h) / 2 + scrollTop;
	ag.style.left = x + "px";
	ag.style.top = y + "px";
	if(!isConfirm){
		$("btnSysMsgOk").focus();
		$("btnSysInfoClose").onclick = function () {
			document.body.removeChild(br);
			if (okCallbak) {
				okCallbak();
			}
			setHideEleByTagName("select","");
			return false;
		};
		$("btnSysMsgOk").onclick = function () {
			$("btnSysInfoClose").onclick();
		};
	}else{
		if(def){
			$("btnSysMsgOk").focus();
		}
		$("btnSysMsgNo").focus();
		$("btnSysMsgOk").onclick = function () {
			document.body.removeChild(br);
			if (okCallbak) {
				okCallbak();
			}
			setHideEleByTagName("select","");
			return false;
		};
		$("btnSysInfoClose").onclick = function(){
			document.body.removeChild(br);
			if (cancelCallbak) {
				cancelCallbak();
			}
			setHideEleByTagName("select","");
			return false;
		}
		$("btnSysMsgNo").onclick = function () {
			$("btnSysInfoClose").onclick();
		};
	}
	return false;
}
